<?php
/**
 * aheadWorks Co.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://ecommerce.aheadworks.com/LICENSE-L.txt
 *
 * @category   AW
 * @package    AW_Blog
 * @copyright  Copyright (c) 2009-2010 aheadWorks Co. (http://www.aheadworks.com)
 * @license    http://ecommerce.aheadworks.com/LICENSE-L.txt
 */

class Pauler_Searchseo_Block_Manage_Searchseo_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
{
	protected function _prepareForm()
    {
        if(Mage::registry('searchseo_data')->getId()){
          $disabled = 'disabled';
        }
        if(0 !=Mage::registry('searchseo_data')->getNumResults()){
           $redirectDisabled = 'disabled'; 
        }
		$form = new Varien_Data_Form();
		$this->setForm($form);
		$fieldset = $form->addFieldset('searchseo_form', array('legend'=>Mage::helper('searchseo')->__('SearchSeo information')));
		
		$fieldset->addField('query_text', 'text', array(
		  'label'     => Mage::helper('searchseo')->__('Keyword'),	
          'name'      => 'searchseo[query_text]',
          'disabled'=>$disabled,
		));
		$fieldset->addField('num_results', 'text', array(
		  'label'     => Mage::helper('searchseo')->__('Num Results'),	
          'name'      => 'searchseo[num_results]',
           'disabled'=>$disabled,
      ));		

	$fieldset->addField('popularity', 'text', array(
		  'label'     => Mage::helper('searchseo')->__('Popularity'),	
          'name'      => 'searchseo[popularity]',
        'disabled'=>$disabled,
    ));
    if(1 ==Mage::registry('searchseo_data')->getNumResults() && false){
            $fieldset->addField('url', 'textarea', array(
		  'label'     => Mage::helper('searchseo')->__('Product Url'),	
          'name'      => 'url',
          'disabled'=>'disabled', 
      ));    
    }else{
	  $fieldset->addField('redirect', 'text', array(
		  'label'     => Mage::helper('searchseo')->__('Redirect ID'),	
          'name'      => 'searchseo[redirect]',
          'idisabled' => $disabled,
          'after_element_html' => 'category id',
      ));        
    }
		$fieldset->addField('is_active', 'select', array(
		'label'     => Mage::helper('searchseo')->__('Status'),
		'name'      => 'searchseo[is_active]',
		'values'    => array(
		  array(
			  'value'     => 1,
			  'label'     => Mage::helper('searchseo')->__('Enabled'),
		  ),
		
		  array(
			  'value'     => 2,
			  'label'     => Mage::helper('searchseo')->__('Disabled'),
		  ),		  		  
		),
		'after_element_html' => '',
		));	  		
		if ( Mage::getSingleton('adminhtml/session')->getBlogData() )
		{
		  $form->setValues(Mage::getSingleton('adminhtml/session')->getBlogData());
		  Mage::getSingleton('adminhtml/session')->setBlogData(null);
		} elseif ( Mage::registry('searchseo_data') ) {
		  $form->setValues(Mage::registry('searchseo_data')->getData());
		}
		return parent::_prepareForm();
  }
  
}
